//==============================================================================
// Copyright (c) 2008-2013 Niall Ryan. All Rights Reserved.
//==============================================================================

#ifndef HYDRA_LOCKS_TASLOCK_H
#define HYDRA_LOCKS_TASLOCK_H 1

#include "hydra/backoff/Backoff.h"

namespace Hydra
{
	class TASLock
	{
	public:
		TASLock()
		{
			m_flag = false;
		}
		void lock()
		{
			Backoff backoff;
			while( m_flag.getAndSet(true) )
			{
				backoff.wait();
			}
		}
		void unlock()
		{
			m_flag = false;
		}
	private:
		Atomic<bool> m_flag;
	};
}

#endif
